﻿@model IPagedList<Domain.Entidades.VW_usuarios>
@using PagedList;
@using PagedList.Mvc;
@{

    Layout = "~/Areas/Intranet/Views/Shared/_Layout2.cshtml";

}
@Scripts.Render("~/bundles/jqueryui2")


<script>


    function criaJanela(nome, conteudo, parametros) {
        nova = open("", nome, parametros);
        nova.document.write(conteudo);
        nova.focus();
    }


    $().ready(function () {



        $("#combo_filtros").slideUp();

        $("#tipo").bind("change", function () {


            if ($("#tipo").val() != 'qual') {

                $("#combo_filtros").slideDown();

                $.getJSON("GetTipo", { tipo: $("#tipo").val() }, function (result) {


                    data = $.parseJSON(result);

                    $("#set_uni").empty();

                    for (var i = 0; i < data.length; i++) {

                        var item = data[i];
                        //$('<input />', { type: 'checkbox', id: 'tipos',name:'tipos', value: item.desc}).appendTo('#listadechk');

                        $("#set_uni").append("<option value=" + item.id + ">" + item.desc + "</option>")
                       
                    }



                });

            }
            else
                $("#combo_filtros").slideUp();
        });

    });


</script>


<div id="topico" class="topico">Colaboradores</div>
<div class="box_medio">

    @using (Html.BeginForm(null, null, FormMethod.Post, new { @id = "formPesquisa" }))
    {
        @Html.ValidationSummary(true)

        <div class="editor-field">
            <label class="txtLabel">
                Por:
            </label>

            <select id="tipo" name="tipo">
                <option value="qual" selected>[Qualquer]</option>
                <option value="set">Setor</option>
                <option value="uni">Unidade</option>
            </select>

            <div id="combo_filtros" name="combo_filtros">
                <label class="txtLabel">
                    Filtro:
                </label>
                <select id="set_uni" name="set_uni"></select>
            </div>

            <label class="txtLabel">
                Nome:
            </label>
            <input type="text" name="nome" id="nome" />

        </div>


        <input id="enviar" type="submit" value="Buscar" class="btn" />


  <a href="~/Intranet_/Usuarios/Imprimir?tipo=@ViewBag.tipo&set_uni=@ViewBag.set_uni&nome=@ViewBag.nome" target="_blank">
     <div class="btn"><img src="/Imagens/Intranet/opcoes/print.png" />Imprimir</div></a>


    }

</div>

<table class="table table-action">

    <thead>
        <tr>
            <th>
                Login
            </th>
            <th>
                Nome
            </th>
            <th>
                Setor
            </th>
            <th>
                Unidade
            </th>
            <th>
                Email
            </th>
            <th>
                ICQ
            </th>
            <th>
                Tel/Ramal
            </th>

        </tr>
    </thead>
        @foreach (var example in Model)
        {


            <tr>
                <td>
                    @example.usu_login
                </td>
                <td>
                    @example.usu_nome
                </td>

                <td width="70px">
                    @example.set_descricao
                </td>

                <td>
                    @example.uni_descricao
                </td>

                <td>
                   @if (example.usu_email.IndexOf('@') < 0)
                   {
                    @Html.Raw(example.usu_email + "@credivale.org.br")
                   }
                   else
                   {
                    @example.usu_email
                   }


                </td>
                <td>
                    @example.usu_icq
                </td>
                <td>

                    @if (example.usu_tel != null)
                    {
                        if (example.usu_tel.ToString().Trim().Length > 0)
                        {

                            @Html.Raw("(") @example.usu_tel.ToString().Substring(0, 2) @Html.Raw(")") @example.usu_tel.ToString().Substring(2, 4) @Html.Raw(" - ") 
                            @example.usu_tel.ToString().Substring(6, 4) @Html.Raw("(")@example.usu_ramal @Html.Raw(")")


                        }
                    }

                   

                        </td>


                    </tr>


        }




</table>



@Html.PagedListPager(Model, page => Url.Action("Lista", new { page, tipo = ViewBag.tipo, set_uni = ViewBag.set_uni, nome = ViewBag.nome }))


